import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../units/iconfont.dart';
import '../provide/setting.dart';
import 'package:provide/provide.dart';
class  BottomBar extends StatefulWidget {
  
  @override
  BottomBarState createState() =>  BottomBarState();
}
class BottomBarState extends State<BottomBar> {


  @override
  void initState() {
  
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
   
    return BottomAppBar(
      color: Colors.white,
      child: Container(
        width: ScreenUtil().setWidth(1080),
        height: ScreenUtil().setHeight(140),
        child:Provide<SettingProvide>(
          builder: (context,child,index){
              return  Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
      getBtmItem(Icon(IconFont.icon_duowei,color:index.selectIndex==0?Colors.black:Colors.grey[600]),"du",0,context),
      getBtmItem(Icon(IconFont.icon_shop2,color:index.selectIndex==1?Colors.black:Colors.grey[600]),"购买",1,context),
      getBtmItem(Icon(IconFont.icon_tubiaolunkuo_,color: index.selectIndex==2?Colors.black:Colors.grey[600],
      ),"动态",2,context),
      getBtmItem(Icon(IconFont.icon_wo,color: index.selectIndex==3?Colors.black:Colors.grey[600],),"我",3,context),
  
      ],
      );
          },
        ) 
      
    ));
 
}
}
getBtmItem(Icon icon,String text,int index,context){
 return FlatButton(
   onPressed:()=>{
     Provide.value<SettingProvide>(context).selectBar(index,context)
   },
   child:Column(
   mainAxisAlignment: MainAxisAlignment.center,
   children: <Widget>[
      icon,
      Text(text)
   ],
 )
 ) ;
}